//
//  SLabelViewController.swift
//  SwiftDemo
//
//  Created by huan liu on 2018/12/11.
//  Copyright © 2018年 xingweixin. All rights reserved.
//

import UIKit

class SLabelViewController: UIViewController {

    var textLabel:UILabel?
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.initNav()
        self.initView()
        
    }
    
    //初始化视图
    func initNav() -> Void {
        
        title = "UILabel"
        view.backgroundColor = UIColor.white;
        
        
    }

    func initView() -> Void {
        
        self.textLabel = UILabel(frame: CGRect(x: 30, y: 100, width: UIScreen.main.bounds.width-60, height: 30))
        self.textLabel?.text = "UIlabel测试"
        self.textLabel?.backgroundColor = UIColor.yellow
        self.textLabel?.textColor = UIColor.black
        self.textLabel?.font = UIFont.systemFont(ofSize: 18)
        self.textLabel?.textAlignment = .center
        self.textLabel?.numberOfLines = 0
        view.addSubview(textLabel!)
        
        /*
         文字过长时
         case byClipping // Simply clip 截去多余部分不显示省略号
         
         case byTruncatingHead // Truncate at head of line: "...wxyz"
         
         case byTruncatingTail // Truncate at tail of line: "abcd..."
         
         case byTruncatingMiddle // Truncate middle of line:  "ab...yz"
        */
        
        textLabel?.lineBreakMode = .byTruncatingHead
        
        
    }
    
    

}
